package com.atguigu.singleton.type7;

/**
 * 单例模式
 * 枚举类
 *
 * @author tielei
 * @date 2021-11-18 17:36
 */
public class SingletonTest07 {
    public static void main(String[] args) {
        Singleton instance = Singleton.INSTANCE;
        Singleton instance1 = Singleton.INSTANCE;
        System.out.println(instance == instance1);
        System.out.println(instance.hashCode() == instance1.hashCode());
    }
}

enum Singleton {
    INSTANCE;
    public void sayOK() {
        System.out.println("ok~");
    }
}
